package com.jsx.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.jsx.model.Addtest;
import com.jsx.dao.UserDao;
import com.jsx.model.User;
import com.jsx.model.Denglu;
//改了
import com.jsx.model.Zhuce;
import com.jsx.service.UserService;

@Service("userService")
public class UserServiceImpl implements UserService{
    @Autowired
    private UserDao userDao;
    public UserDao getUserDao() {
        return userDao;
    }
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    //改了
    public String addInfo(Zhuce addInfo) {
        if (userDao.insertSelective(addInfo) == 1) {
            return "添加成功";
        }
        return "添加失败";
    }

    @Override
    //添加测试练习
    public String Addtest1(Addtest addInfo) {
        if (userDao.addSelective(addInfo) == 1) {
            return "添加成功";
        }
        return "添加失败";
    }

    @Override
    public List<User> getAll() {
        return userDao.getAll();
    }
    @Override
    public String delete(int id) {
        if (userDao.deleteByPrimaryKey(id) == 1) {
            return "删除成功";
        }
        return "删除失败";
    }
    @Override
    public Addtest findById(int id) {
        return userDao.selectByPrimaryKey(id);
    }
    @Override
    public String update(Addtest addInfo) {
        if (userDao.updateByPrimaryKeySelective(addInfo) == 1) {
            return "修改成功";
        }
        return "修改失败";
    }
    @Override
    //管理员登录
    public Denglu login1(Denglu user) {
        return userDao.selectByUsernameAndPassword(user);
    }

    @Override
    //用户登录
    public Denglu loginyonghu(Denglu user) {
        return userDao.selectByUsernameAndPasswordyonghu(user);
    }
}
